<template>
  <div class="tab-bar-item" @click="routerClick">
    <slot name="item-icon" v-if="!isactive"></slot>
    <slot name="item-icon-active" v-else></slot>

    <div :class="{ active: isactive }">
      <slot name="item-text"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "tabBarItem",
  data() {
    return {};
  },
  props: ["tag"],
  methods: {
    routerClick() {
      this.$router.push(this.tag);
    },
  },
  computed: {
    isactive() {
      return this.$route.path.indexOf(this.tag) !== -1;
    },
  },
};
</script>

<style scoped>
.tab-bar-item {
  flex: 1;
  height: 49px;
  font-size: 14px;
  text-align: center;
}
.tab-bar-item img {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  margin-top: 3px;
}
.active {
  color: rgb(235, 91, 175);
}
</style>
